<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String user_name = (session
			.getValue("SPRING_SECURITY_LAST_USERNAME")).toString();
%>
<html>
	<head>
		<title>零序电流曲线</title>
		<link id=style href="../styles/theme/blue/frame.css" type="text/css"
			rel="stylesheet" />
		<style type="text/css">
.divLinechart {
	width: 100%;
	margin: 5px;
}
</style>
		<script type='text/javascript' src='../ajax-pushlet-client.js'></script>
		<script type='text/javascript' src='../js/jquery.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/jquery.blockUI.js'></script>
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/js/highcharts.js"></script>
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/js/highChartsTheme.js"></script>
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/scripts/curveCommon.js"></script>
		<script>
		function onData(event) {
	
			// 获取零序电流串，再将其分割成数组，最后转换成Double型
			var zeroSequenceCurrentData = event.get("zeroSequenceCurrentData");
			var zeroSequenceCurrentDataArr = zeroSequenceCurrentData.split(":");
			
			var zeroSequenceCurrentDataArrDouble = new Array();
			for (var i=0; i<zeroSequenceCurrentDataArr.length; i++) {
				zeroSequenceCurrentDataArrDouble[i] = parseFloat(zeroSequenceCurrentDataArr[i]);
			}
				
			// 修正各曲线的最大值
			var fCorrectYAxisMax = correctYAxisMax(zeroSequenceCurrentDataArrDouble, 2/3);
			
			var maxVal = -999999999;
			maxVal = fCorrectYAxisMax > maxVal ? fCorrectYAxisMax : maxVal;
			maxVal = maxVal > 0.0 ? maxVal : 10;
			
			// 修正各曲线的最小值
			var fCorrectYAxisMin = correctYAxisMin(zeroSequenceCurrentDataArrDouble, 2/3);
			
			var minVal = 0;
			minVal = fCorrectYAxisMin < minVal ? fCorrectYAxisMin : minVal;
		
			// 准备时间
			var startTime = event.get("startTime");
			var time = new Array();
			time[0] = startTime;
			var date= new Date(Date.parse(startTime.replace(/-/g,   "/"))); 
			for (var i=1; i<zeroSequenceCurrentDataArr.length; i++) {
				var date2Minsec = date.getTime();
				var addFifteen = 1000 * 60 * 15;
				date2Minsec += addFifteen;
				date = new Date(date2Minsec);
				time[i]= date2Str(date);
			}
			
			// 创建折线图，生成后放置在id为container的div中
			titleText = "零序电流曲线";
			colors = otherColor;
			yAxisText = "零序电流(A)";
			unit = "A";
			seriesVal = [{
				name: '零序电流',
				data: zeroSequenceCurrentDataArrDouble
			}];
			var container = parent.window.frames["lineChart"].document.getElementById("container");
			
			var chart = showChart(container, titleText, startTime, colors, time, yAxisText, maxVal, minVal, unit, seriesVal);
		}

// pushlet ajax开始，监听/source/zeroSequenceCurrent的报文
PL._init('<%=user_name%>');
PL.joinListen('/source/zeroSequenceCurrent');
</script>
	</head>
	<body style="overflow-y: hidden; overflow-x: hidden">
		<div class="divLinechart" id="container">
		</div>
	</body>
</html>
